﻿var sql=require("./../node_modules/mysql");
function wodeConn(){
    var wodeconn=sql.createConnection({
        host:"localhost",
        port:"3306",
        user:"root",
        password:"824077985",
        database:"mylhl"
    });
    return wodeconn;
}

/*我的预约订座的数据库传输数据*/
exports.wenZi = function(req,resp){
    var wodeconn = wodeConn();
    console.log("数据库链接成功");
    console.log(req.body.li);
    var zhi = req.body.li.split(",");
    var name = zhi[0];
    var riqi = zhi[1];
    var time = zhi[2];
    var ting = zhi[3];
    console.log(riqi);
    wodeconn.connect();
    var mysql1 = "INSERT INTO dingdan(dingdan_movie,dingdan_riqi,dingdan_time,dingdan_yingting) " +
        "VALUES"+ "(?,?,?,?)";
    wodeconn.query(mysql1,[name,riqi,time,ting]);

    var mysql = "SELECT * FROM dingdan WHERE dingdan_id=1";
    wodeconn.query(mysql,[],function(err,data){
        //console.log(mysql);
        console.log(err);
        resp.send(data);
        console.log(data);
    });

    wodeconn.end();
    console.log("数据上传成功");
};

